package com.action;

import com.action.abs.AbstractBaseAction;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@RestController // 直接基于Rest架构进行处理，省略了@ResponseBody注解
@RequestMapping("/object/*") // 添加父路径
public class ObjectAction extends AbstractBaseAction { // 控制层的实现类
    @RequestMapping("first") // 子路径
    public Object firstShow(HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<>();
        result.put("【request】contextPath", request.getContextPath());
        result.put("【request】messageParam", request.getParameter("message"));
        result.put("【request】method", request.getMethod());
        result.put("【session】sessionId", request.getSession().getId());
        result.put("【application】VirtualServerName", request.getServletContext().getVirtualServerName());
        result.put("【application】InitParameter", request.getServletContext().getInitParameter("teacher"));
        return result;
    }

    //http://localhost:8082/test/object/second?message=Spring%20Boot%E5%BC%80%E5%8F%91%E5%AE%9E%E6%88%98%20www.baidu.com
}
